package org.com.yz.dubbo.web.core;

import cn.hutool.core.date.DateUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONObject;
import org.com.yz.common.util.PayDigestUtil;

import java.util.HashMap;

/**
 * @ClassName MchNoTest
 * @Author wzc
 * @Date 2018/8/15 14:40
 **/
public class MchNoTest {


    public static void main(String[] args) {
        for (int i = 0; i < 1; i++) {
            HashMap<String, Object> paramMap = new HashMap<>( );
            JSONObject jsonObject = new JSONObject( );
            JSONObject jsonObject2 = new JSONObject( );
            JSONObject jsonObject3 = new JSONObject( );
            JSONObject jsonObject4 = new JSONObject( );
            String time = org.com.yz.common.util.DateUtil.getSeqString( );  //时间戳


            jsonObject2.put("mch_accnt_name","小码云商户");
            jsonObject2.put("out_mch_accnt_no","009"+i);
            jsonObject2.put("link_name","小晶晶"+i);
            jsonObject2.put("lindk_phone","110"+i);
            jsonObject2.put("link_email","99888@qq.com"+i);

                jsonObject3.put("card_no", "62290812100012740" );
                jsonObject3.put("mch_accnt_no", "T00201807270929320022");
                jsonObject3.put("bank_name", "中国农业银行");
                jsonObject3.put("cert_type", "0");
                jsonObject3.put("card_type", "0");
                jsonObject3.put("user_name", "Undead");
                jsonObject3.put("card_phone", "13111111111");
                jsonObject3.put("cert_no", "310101198701010019");
                jsonObject2.put("bank_cards",jsonObject3);   //装卡

            jsonObject4.put("mch_accnts",jsonObject2);

            jsonObject.put("mch_no", "8AAA");  //商户号
            jsonObject.put("out_trans_no", "f26c31c7-333a-4c5f-91b6-4ad66566d3b2"+i);  //请求追踪号
            jsonObject.put("biz_type", "mchsub.batchcreate");  //交易类型
            jsonObject.put("sign_type", "MD5");  //交易类型
            jsonObject.put("biz_content", jsonObject4);   //请求的业务数据
            jsonObject.put("timestamp", time);

            String jsonString = jsonObject.toString( ) + "&" + time + "9b389216c3c55a7c535510b33b9e6ea6";
            String sign = PayDigestUtil.md5(jsonString, "UTF-8");
            System.out.println(jsonObject );
            paramMap.put("data", jsonObject);
            paramMap.put("sign", sign);
            String result = HttpUtil.post("http://localhost:3020/api/deposit.htm", paramMap);
            System.out.println(result);
        }
    }
}
